Auto-size sidebar pane to fit the widest menu label#142
Merged
Conversation
The previously hardcoded OpenPaneLength="185" clipped English labels like "Software information", "Donate to the author", and "Backup and restore", as well as longer translations such as de-DE "Programmeinstellungen" / "Backup-Wiederherstellung", pt-BR "Configurações do Programa", tr-TR "Yedekleme ve Geri Yükleme", and ru-RU "Поблагодарить автора". Computes the required pane length at startup from the actual labels: the natural width of each item's text (via FormattedText at the NavigationView's typeface/size/DPI) plus role-specific chrome measured against iNKORE.UI.WPF.Modern v0.10.2's NavigationViewItem template — 100px for expandable parents (icon + chevron slot), 74px for icon-only footer leaves, 67px for nested leaves. Result is clamped to [185, 400] so section items with short text don't shrink the pane below the original width and no single pathological label eats the content area. Since language changes trigger SingleInstance.Restart(), the calculation runs exactly once per launch.
Jack251970
approved these changes
Apr 23, 2026
Owner
|
Thanks for your contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MainWindow.xamlhardcodedNavigationView.OpenPaneLength="185", which was tuned for short Chinese labels. Longer English footer labels ("Software information", "Donate to the author", "Backup and restore") get truncated, as do translations like de-DE "Programmeinstellungen" / "Backup-Wiederherstellung", pt-BR "Configurações do Programa", tr-TR "Yedekleme ve Geri Yükleme", and ru-RU "Поблагодарить автора". WinUI'sNavigationView(and therefore iNKORE's WPF port) intentionally exposesOpenPaneLengthas a fixeddouble— there is noPaneSizeMode=Autoor equivalent upstream, so this has to live in the app.Changes
OpenPaneLength="185"from the NavigationView.MainWindownow computes the required pane length at startup by measuring eachNavigationViewItem's natural text width withFormattedText(using the NavigationView's effective typeface, font size, and per-monitor DPI) and adding role-specific chrome.100for expandable parent items (icon + chevron slot),74for icon-only footer leaves,67for nested leaves without icons.[185, 400]so the pane never shrinks below the previous width and a pathological translation can't push the pane past the content area. Language changes already callSingleInstance.Restart(), so the calculation runs exactly once per launch.